package com.vancouver.knows.ui.view;

import com.pangu.task.mark.ATaskMark;
import com.pangu.ui.refresh.IPullable;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

public class PullScrollView extends ScrollView implements IPullable {

	private ATaskMark aTaskMark;

	public PullScrollView(Context context) {
		super(context);
	}

	public PullScrollView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public void init(ATaskMark aTaskMark) {
		this.aTaskMark = aTaskMark;
	}

	@Override
	public boolean canPullDown() {
		if (aTaskMark == null) {
			return false;
		}

		int taskStatus = aTaskMark.getTaskStatus();
		if (taskStatus == ATaskMark.HANDLE_ERROR || taskStatus == ATaskMark.HANDLE_DOING) {
			return false;
		}

		if (getScrollY() == 0) {
			return true;
		}

		return false;
	}

	@Override
	public boolean canPullUp() {
		return false;
	}

}
